package com.xyh.run.config;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
import org.springframework.security.core.userdetails.UserDetailsService;

/**
 * @version v1.0
 * @类描述：
 * @项目名称：设置用户名和密码
 * @包名： com.xyh.run.config
 * @类名称：MySecurityConfig
 * @创建人：YIHANG.XU
 * @创建时间：2021/11/1110:11 上午
 * @修改人：YIHANG.XU
 * @修改时间：2021/11/1110:11 上午
 * @修改备注：
 * @Copyright
 */

@Configuration
public class MySecurityConfig extends WebSecurityConfigurerAdapter {

    @Bean
    public UserDetailsService userDetailsService() {
        return new MyUserDetails();
    }

    /**
     * 配置类的方式进行密码认证
     */
    @Override
    protected void configure(HttpSecurity http) throws Exception {
       http.requestMatchers().antMatchers("/login","/home").anyRequest().and().//拦截方法
       formLogin().and().logout().and();
    }

}
